/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cl.bussines.entities;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Vogel
 */
@Entity
@Table(name = "clientes")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Clientes.findAll", query = "SELECT c FROM Clientes c"),
    @NamedQuery(name = "Clientes.findByIdClie", query = "SELECT c FROM Clientes c WHERE c.idClie = :idClie"),
    @NamedQuery(name = "Clientes.findByRutClie", query = "SELECT c FROM Clientes c WHERE c.rutClie = :rutClie"),
    @NamedQuery(name = "Clientes.findByDvClie", query = "SELECT c FROM Clientes c WHERE c.dvClie = :dvClie"),
    @NamedQuery(name = "Clientes.findByNombresClie", query = "SELECT c FROM Clientes c WHERE c.nombresClie = :nombresClie"),
    @NamedQuery(name = "Clientes.findByApellidosClie", query = "SELECT c FROM Clientes c WHERE c.apellidosClie = :apellidosClie"),
    @NamedQuery(name = "Clientes.findByDireccionClie", query = "SELECT c FROM Clientes c WHERE c.direccionClie = :direccionClie"),
    @NamedQuery(name = "Clientes.findBySexo", query = "SELECT c FROM Clientes c WHERE c.sexo = :sexo"),
    @NamedQuery(name = "Clientes.findByEMail", query = "SELECT c FROM Clientes c WHERE c.eMail = :eMail"),
    @NamedQuery(name = "Clientes.findByFono", query = "SELECT c FROM Clientes c WHERE c.fono = :fono"),
    @NamedQuery(name = "Clientes.findByFono2", query = "SELECT c FROM Clientes c WHERE c.fono2 = :fono2"),
    @NamedQuery(name = "Clientes.findByFechaNacimiento", query = "SELECT c FROM Clientes c WHERE c.fechaNacimiento = :fechaNacimiento"),
    @NamedQuery(name = "Clientes.findByEstadoCivil", query = "SELECT c FROM Clientes c WHERE c.estadoCivil = :estadoCivil"),
    @NamedQuery(name = "Clientes.findByPassword", query = "SELECT c FROM Clientes c WHERE c.password = :password"),
    @NamedQuery(name = "Clientes.findByCanalComunicacion", query = "SELECT c FROM Clientes c WHERE c.canalComunicacion = :canalComunicacion"),
    @NamedQuery(name = "Clientes.findByInfopublica", query = "SELECT c FROM Clientes c WHERE c.infopublica = :infopublica")})
public class Clientes implements Serializable {
    private static final long serialVersionUID = 1L;
    @Basic(optional = false)
    @Column(name = "id_Clie")
    private int idClie;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "Rut_Clie")
    private String rutClie;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Dv_Clie")
    private String dvClie;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Nombres_Clie")
    private String nombresClie;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "Apellidos_Clie")
    private String apellidosClie;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 200)
    @Column(name = "Direccion_Clie")
    private String direccionClie;
    @Size(max = 1)
    @Column(name = "Sexo")
    private String sexo;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Size(max = 100)
    @Column(name = "EMail")
    private String eMail;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "Fono")
    private String fono;
    @Size(max = 30)
    @Column(name = "Fono2")
    private String fono2;
    @Column(name = "Fecha_Nacimiento")
    @Temporal(TemporalType.DATE)
    private Date fechaNacimiento;
    @Size(max = 45)
    @Column(name = "Estado_Civil")
    private String estadoCivil;
    @Size(max = 45)
    @Column(name = "Password")
    private String password;
    @Size(max = 45)
    @Column(name = "Canal_Comunicacion")
    private String canalComunicacion;
    @Column(name = "Info_publica")
    private Boolean infopublica;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "rutClie")
    private Collection<ClieHasMoto> clieHasMotoCollection;
    @JoinColumn(name = "CUT_Comuna", referencedColumnName = "CUT_Comuna")
    @ManyToOne(optional = false)
    private Comunas cUTComuna;

    public Clientes() {
    }

    public Clientes(String rutClie) {
        this.rutClie = rutClie;
    }

    public Clientes(String rutClie, int idClie, String dvClie, String nombresClie, String apellidosClie, String direccionClie, String fono) {
        this.rutClie = rutClie;
        this.idClie = idClie;
        this.dvClie = dvClie;
        this.nombresClie = nombresClie;
        this.apellidosClie = apellidosClie;
        this.direccionClie = direccionClie;
        this.fono = fono;
    }

    public int getIdClie() {
        return idClie;
    }

    public void setIdClie(int idClie) {
        this.idClie = idClie;
    }

    public String getRutClie() {
        return rutClie;
    }

    public void setRutClie(String rutClie) {
        this.rutClie = rutClie;
    }

    public String getDvClie() {
        return dvClie;
    }

    public void setDvClie(String dvClie) {
        this.dvClie = dvClie;
    }

    public String getNombresClie() {
        return nombresClie;
    }

    public void setNombresClie(String nombresClie) {
        this.nombresClie = nombresClie;
    }

    public String getApellidosClie() {
        return apellidosClie;
    }

    public void setApellidosClie(String apellidosClie) {
        this.apellidosClie = apellidosClie;
    }

    public String getDireccionClie() {
        return direccionClie;
    }

    public void setDireccionClie(String direccionClie) {
        this.direccionClie = direccionClie;
    }

    public String getSexo() {
        return sexo;
    }

    public void setSexo(String sexo) {
        this.sexo = sexo;
    }

    public String getEMail() {
        return eMail;
    }

    public void setEMail(String eMail) {
        this.eMail = eMail;
    }

    public String getFono() {
        return fono;
    }

    public void setFono(String fono) {
        this.fono = fono;
    }

    public String getFono2() {
        return fono2;
    }

    public void setFono2(String fono2) {
        this.fono2 = fono2;
    }

    public Date getFechaNacimiento() {
        return fechaNacimiento;
    }

    public void setFechaNacimiento(Date fechaNacimiento) {
        this.fechaNacimiento = fechaNacimiento;
    }

    public String getEstadoCivil() {
        return estadoCivil;
    }

    public void setEstadoCivil(String estadoCivil) {
        this.estadoCivil = estadoCivil;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getCanalComunicacion() {
        return canalComunicacion;
    }

    public void setCanalComunicacion(String canalComunicacion) {
        this.canalComunicacion = canalComunicacion;
    }

    public Boolean getInfopublica() {
        return infopublica;
    }

    public void setInfopublica(Boolean infopublica) {
        this.infopublica = infopublica;
    }

    @XmlTransient
    public Collection<ClieHasMoto> getClieHasMotoCollection() {
        return clieHasMotoCollection;
    }

    public void setClieHasMotoCollection(Collection<ClieHasMoto> clieHasMotoCollection) {
        this.clieHasMotoCollection = clieHasMotoCollection;
    }

    public Comunas getCUTComuna() {
        return cUTComuna;
    }

    public void setCUTComuna(Comunas cUTComuna) {
        this.cUTComuna = cUTComuna;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rutClie != null ? rutClie.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Clientes)) {
            return false;
        }
        Clientes other = (Clientes) object;
        if ((this.rutClie == null && other.rutClie != null) || (this.rutClie != null && !this.rutClie.equals(other.rutClie))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cl.bussines.entities.Clientes[ rutClie=" + rutClie + " ]";
    }
    
}
